//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tools\fn_CompassDir.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_dir","_dir_list"];
DEFAULT_PARAM(_object,0,objNull);

_dir_list = ["N","N-NE","NE","E-NE","E","E-SE","SE","S-SE","S","S-SW","SW","W-SW","W","W-NW","NW","N-NW","N","N"];
_dir = 0;
if (typename _this == typename []) then {
	_dir = _this select 0;
	if (count _this > 1) then {
		if (count (_this select 1) > 0) then {
			_dir_list = _this select 1;
		} else {
			if (count _this > 2) then {
				if ((_this select 2)) then {
					_dir_list = ["STR_KW_NORTH","STR_KW_NORTH","STR_KW_NORTHEAST","STR_KW_EAST","STR_KW_EAST","STR_KW_EAST","STR_KW_SOUTHEAST","STR_KW_SOUTH","STR_KW_SOUTH","STR_KW_SOUTH","STR_KW_SOUTHWEST","STR_KW_WEST","STR_KW_WEST","STR_KW_WEST","STR_KW_NORTHWEST","STR_KW_NORTH","STR_KW_NORTH","STR_KW_NORTH"];
				};
			};
		};
	};
} else {
	_dir = _this;
};
if (_dir < 0) then {_dir = _dir + 360};
if (_dir > 360) then { _dir = _dir - 360};
_dir = _dir_list select (round (_dir/22.5));

TRACE_1("End",_dir);
TMFPROFILERSTOP;
_dir;